/**
 * 封装错误提示
 */

class HttpException extends Error {
  /**
   * @param  msg 错误消息提示
   * @param  errorCode errorCode标识
   * @param  code 状态码
   */
  constructor(msg = "", errorCode = 10000, code = 400) {
    super();
    this.code = code;
    this.msg = msg;
    this.errorCode = errorCode;
  }
}
/**
 * 默认错误提示
 */
class ParameterException extends HttpException {
  constructor(msg, eroorCode) {
    super();
    this.code = 400;
    this.msg = msg || "参数错误";
    this.errorCode = eroorCode || 10000;
  }
}
/**
 * 成功提示
 */
class Success extends HttpException {
  constructor(msg, eroorCode) {
    super();
    this.code = 200;
    (this.msg = msg || "success"), (this.errorCode = eroorCode || 0);
  }
}
/**
 *  资源未找到
 */
class NotFound extends HttpException {
  constructor(msg, errorCode) {
    super();
    this.code = 404;
    this.msg = msg || "资源未找到";
    this.errorCode = errorCode || 10000;
  }
}
/**
 *  授权失败
 */
class AuthFailed extends HttpException {
  constructor(msg, errorCode) {
    super();
    this.code = 401;
    this.msg = msg || "授权失败";
    this.errorCode = errorCode || 10004;
  }
}

/**
 * 禁止访问
 */
class Forbbiden extends HttpException {
  constructor(msg, errorCode) {
    super();
    this.code = 403;
    this.msg = msg || "禁止访问";
    this.errorCode = errorCode || 10006;
  }
}

module.exports = {
  HttpException,
  ParameterException,
  Success,
  Forbbiden,
  AuthFailed,
  NotFound,
};
